<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title> <?php echo $subject ? $subject : '输错了吧'?> - <?=SITE_NAME?> </title>
<?php include VIEWS.'header.html'?>

<script type="text/javascript">
<!--
function open_topic() {$('c_text','newtopic').invoke('show');$('o_text','topiclist').invoke('hide');$('newtopicform').focusFirstElement()}
function close_topic() {$('c_text','newtopic','updatemsg').invoke('hide');$('o_text','topiclist').invoke('show')}
<?php if($_GET['new']):?>window.onload=open_topic;<?php endif?>
//-->
</script>

<script type="text/javascript">
<!--
var aa = ajaxStart();
var timer = null;

function newPost() {
    var f = $('newtopicform');
    $('submit').disabled = true;

    $('updatemsg').hide();
    $('loading').show();

    try {
        aa.call('/forum.php/<?php echo $data['id']?>/new', 'ajaxNewPost', newPost_result, $('newtopicform').serialize());
        return false;
    } catch (e) {
        return true;
    }
}

function newPost_result(result) {
    var i;
    var d = $('updatemsg');
    var err = 0;
    var ok = 0;

    $('loading').hide();

    try {
        var stat = result.result[0].data;
        switch(stat) {
            case 16:
                i = '姓名不能为空哦';err = 1;$('uname').focus();break;
            case 32:
                i = '请检查您的Email是否正确';err = 1;$('umail').focus();break;
            case 4:
                i = '别忘了输入标题哦';err = 1;$('subject').focus();break;
            case 8:
                i = '您想要说什么呢';err = 1;$('body').focus();break;
            case 128:
                i = '朋友，您输入的验证码好像不正确';err = 1;$('rand_code').focus();break;
            case 1:
                i = '发表成功，正转到列表页';ok = 1;break;
            default:
                err = 1;i = '未知错误('+stat+')，请稍候再试';
        }
    } catch(e) {
        i = '服务器错误，请稍候再试';
        err = 1;
    }

    if (err==1) {
        d.style.backgroundColor= '#FF6600';
        d.style.color= '#FFF';
    } else {
        d.style.backgroundColor= '#DDF63E';
        d.style.color= '#000';
    }

    $('submit').disabled = false;
    d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
    $('updatemsg').show();
    new Effect.Round('div', 'updatemsg');
    if (timer) window.clearTimeout(timer);
    timer = setTimeout( "$('updatemsg').style.display='none';", 10000);
    if (ok==1) setTimeout( "location.href='/forum/<?php echo $data['id']?>';", 500);
}
//-->
</script>

<style type="text/css">
#topiclist {
    text-align: center;
}

.tt{
    width: 98%;
    padding: 0;
}

.tt td{
    border-bottom: 1px dotted #CCCCCC;
    font-size: 12px;
}

.ti {
    line-height: 150%;
    text-align: left;
}
</style>

<?php if(!$data['id']):?><script type="text/javascript">location.href='/forum/1';</script><?php endif?>

</head>

<body>
<?php include VIEWS.'topbar.html'?>

<div id="content">

    <?php include VIEWS.'leftnav.html'?>

    <div id="right">
    <?php include VIEWS.'sidesearch.html'?>
    <h1><?php echo $subject ? $subject : '输错了吧'?></h1>

<?php if($code['forum'] == 4):?>
    <div class="errbox roundNormal">&nbsp;&nbsp;&nbsp;是不是输入错了？</div>
<?php else:?>

    <div id="o_text" style="margin:10px"><img src="/images/icon_arrow_right.gif" alt="arrow right" /><a onclick="javascript:open_topic();return false" href="/forum/<?php echo $data['id']?>/new">新话题</a></div>
    <div id="c_text" style="margin:10px;display:none"><img src="/images/icon_arrow_down.gif" alt="arrow down" /><a onclick="javascript:close_topic();return false" href="/forum/<?php echo $data['id']?>">取消发表</a></div>
    <br clear="all" />

    <div style="text-align:left;font-size:12px;margin-left:20px"><?php echo $body?></div><br clear="all" />

    <div id="newtopic" style="display:none;text-align:left;margin-left:30px">
        <div id="loading" style="display:none;padding-left:1em"><img src="/images/icon_indicator.gif" width="220" height="19" alt=""  /></div>
        <div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#DDF63E;font-size:12px;width:100%;display:none;">&nbsp;</div><br clear="all" />
        <form action="/forum.php/<?php echo $data['id']?>/new" method="post" id="newtopicform" onsubmit="javascript:return newPost();">
        <table>
        <?php if(!$session['login']):?><tr><td>姓名：</td><td><input class="input1" tabindex="2" id="uname" value="<?php echo $data['uname']?>" size="8" maxlength="20" type="text" name="uname" /> &nbsp; <a tabindex="100" style="font-size:12px" href="/login?from=<?php echo urlencode("/forum/{$data['id']}?new=1")?>">会员请登录</a></td></tr><?php endif?>
        <?php if(!$session['login']):?><tr><td>Email：</td><td><input class="input1" tabindex="2" id="umail" value="<?php echo $data['umail']?>" size="20" maxlength="60" type="text" name="umail" /></td></tr><?php endif?>
        <tr><td>标题：</td><td><input class="input2" tabindex="2" id="subject" value="<?php echo $data['subject']?>" size="30" maxlength="100" type="text" name="subject" /></td></tr>
        <tr><td valign="top">内容：</td><td><textarea tabindex="2" id="body" name="body" rows="10" cols="60"><?php echo $data['body']?></textarea></td></tr>
        <?php if (!$session['login']):?><tr><td>验证码：</td><td><input tabindex="2" id="rand_code" class="px12" type="text" name="rand_code" value="" size="8" maxlength="4" /> &nbsp; <img alt="" id="rand_code_img" src="/rand_code.php" style="vertical-align:absmiddle" /> &nbsp; <font class="px12">请输入左侧图片中的数字</font></td></tr><?php endif?>
        </table>
        <div style="text-align:left;margin:10px;margin-left:60px"><input accesskey="s" tabindex="3" id="submit" type="submit" value="发表新话题" class="bluebtn" style="font-weight:bold" /> &nbsp; <input tabindex="3" type="reset" onclick="javascript:close_topic()" value="取消" class="darkbtn" /></div>
        </form>
    </div>

    <div id="topiclist">
        <?php if(count($list)):?>
        <?php echo round_table('98%', '244890', 'white', 2, 2, 'top')?>
        <table class="tt" cellspacing="0">
        <tr class="ti" style="font-weight:bold;background-color:#244890;color:#FFF"><td>&nbsp;&nbsp;标题</td><td>作者</td><td nowrap="nowrap">回复</td><td>最新回复</td></tr>
        <?php foreach ($list as $v):?>
        <tr class="ti"><td>&nbsp; <a href="/forum/<?php echo $data['id']?>/<?php echo $v['id']?>"> <?=utf8_substr($v['subject'], 0, 30)?> </a></td><td><?php echo $v['uname'] ? $v['uname'] : 'guest'?></td><td nowrap="nowrap"><?php echo $v['tcount']?></td><td nowrap="nowrap"><?php echo date('y/m/d H:i', $v['updated'])?></td></tr>
        <?php endforeach?>
        </table>

        <?php if($page['next']):?><div style="text-align:right;margin:0.8em"><a class="px12" tabindex="3" href="<?php echo $page['url']?>p=<?php echo $page['next']?>"><?=str_repeat('更', $page['p']>10?10:$page['p'])?>早的话题</a> &raquo; </div><?php endif?>

        <?php else:?>
        <div class="goodbox roundNormal">&nbsp;&nbsp;&nbsp;暂时没有话题</div>
        <?php endif?>
    </div>

<?php endif?>

    </div>
</div>

<?php include VIEWS.'copyright.html'?>

</body>
</html>
